package com.westos.echufang.config.handler;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginHandlerInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object loginEmployee = request.getSession().getAttribute("loginEmployee");
        Object loginAdmin = request.getSession().getAttribute("loginAdmin");

        if (loginEmployee==null&&loginAdmin==null){
            request.setAttribute("loginMsg","请登录");
            request.getRequestDispatcher("/").forward(request,response);
            return false;
        }else return true;
    }
}
